interface User {
  name: string;
  age: number;
}
interface Menoy {
  count: number;
}
// 交叉类型： 满足所有类型
const param: User & Menoy = {
  name: "张安",
  age: 18,
  count: 1231,
};

// 联合类型： 满足任意一个类型即可
const param1: User | Menoy = {
  count: 123,
};

const arr123: (string | number)[] = ["1", "2", "3"];

// 类型保护与区分类型（Type Guards and Differentiating Types）
const el = document.querySelector(".main");

if (el) {
  el.addEventListener("click", () => {});
}

let num123: undefined | number = undefined;
num123 = 123

if(typeof num123 !== 'undefined') {
	const result = num123 + 1
}
// 非空断言
el!.className;
// ES6 写法
el?.className;

// 类型断言
(el as Element).className;
(<Element>el).className

